package com.yyfax.ph.personal.mymoney.withdraw;

import com.yyfax.common.CLog;
import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;


/**
 * 项目名称: YYLending
 * 类描述： 获取绑定申请的子账户列表
 * 创建人: zhangxian
 * 创建时间: 2016/12/19 15:58
 * 修改人: zhangxian
 * 修改时间: 2016/12/19 15:58
 * 修改备注:
 */

public class WithDrawModel extends Model {
	private static final String TAG = WithDrawModel.class.getSimpleName();

    @Override
    public Observable getObservable(Object params, int functionalCode) {
        Service service = (Service) NetworkHelper.createService(Service.class);
        String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
        return service.getCompanyInfo(token, (Money) params);
    }

    @Override
    public void onNext(Object entity) {
		CLog.i(TAG, "onNext: " + entity.toString());
        WithdrawResult result = cast(entity);
        EventAgent.post(result);
    }

    interface Service{
        @POST("account/balance/withdraw")
        Observable<WithdrawResult> getCompanyInfo(@Header("token") String token, @Body Money params);
    }

    static class Money{
        public String money;
        public Money(String money) {
            this.money = money;
        }
    }

    static class WithdrawResult extends BaseResultEntity{}
}
